package ro.myApp.commons.utils;

import java.util.Collection;

public class CustomAssertion extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5430689447546060671L;
	
	private static final String NO_MESSAGE = "message undefined";

	private CustomAssertion() {
		super();
	}
	
	private CustomAssertion (String details){
		super(details);
	}
	
	public static void assertTrue (boolean b, String message){
		if (b == false) {
 			throw new CustomAssertion("Assertion has failed: " + message);
		}
	}
	
	public static void assertTrue (boolean b){
		assertTrue(b, NO_MESSAGE);
	}
	
	public static void assertFalse (boolean b, String message){
		assertTrue(!b, message);
	}
	
	public static void assertFalse (boolean b){
		assertTrue(!b);
	}
	
	public static void assertNull (Object b, String message){
		assertTrue(null==b, message);
	}
	
	public static void assertNull (Object b){
		assertTrue(null==b);
	}
	
	public static void assertNotNull (Object b, String message){
		assertTrue(null!=b, message);
	}
	
	public static void assertNotNull (Object b){
		assertTrue(null!=b);
	}

	public static void assertNotEmpty (String b, String message){
		assertTrue(null!=b && !b.isEmpty(), message);
	}
	
	public static void assertNotEmpty (String b){
		assertNotEmpty(b, "");
	}
	
	public static void assertNotEmpty (Collection<?> b, String message){
		assertTrue(null!=b && !b.isEmpty(), message);
	}
	
	public static void assertNotEmpty (Collection<?> b){
		assertNotEmpty(b, "");
	}
}
